/**
 * 
 */
package com.dy.agent.agent.api.exception;

public class CommonException extends RuntimeException {

	private static final long serialVersionUID = 5364500292218636442L;

	private static final BaseErrorCode DEFAULT_ERRORCODE = CommonErrorCode.UNKNOW;

	protected String message;
	protected transient BaseErrorCode errorCode;

	public CommonException() {
	}

	public final BaseErrorCode getErrorCode() {
		if (this.errorCode == null) {
			return DEFAULT_ERRORCODE;
		}
		return errorCode;
	}

	@Override
	public final String getMessage() {
		if (this.message == null) {
			return this.getErrorCode().getMsg();
		}
		return this.message;
	}
}
